package com.ojoin.trade.supplyloan_core.web.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ojoin.trade.common.exception.BusinessException;
import com.ojoin.trade.common.utils.json.JSONUtils;
import com.ojoin.trade.common.web.controller.SimpleBaseController;
import com.ojoin.trade.common.web.domain.Result;
import com.ojoin.trade.supplyloan_core.web.domain.TbSlStatetaskRunresultvo;
import com.ojoin.trade.supplyloan_core.web.service.TbSlStattaskRunresultService;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 15-11-11
 * Time: 上午11:42
 * To change this template use File | Settings | File Templates.
 */
 @Controller
 @RequestMapping("/tattaskRunresult")
 public class TbSlStattaskRunresultController  extends SimpleBaseController {

   private Logger log= LoggerFactory.getLogger(TbSlStattaskRunresultController.class);
    @Autowired
   private TbSlStattaskRunresultService tbSlStattaskRunresultService;

    //查询所有的监控数据
    
    @ResponseBody
    @RequestMapping(value = "operate/queryalltbsltaskrunresulttoday", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
    public Result queryAllTbSltaskRunresultToday(HttpServletRequest request,String platformName,String merchantUserId,String statDate,Pageable page){
       log.info("platformName->"+platformName+"" +
       		"merchantUserId->" +
       		"statDate->"+statDate);
     try{   
    	    
    	 List<TbSlStatetaskRunresultvo>  list=tbSlStattaskRunresultService.queryByPlatformAndMerchantUserIDAndDate(platformName, merchantUserId, statDate, page);
         log.info(JSONUtils.toJSONString(null != list ?list.size():null));
 
    	 return new Result(Result.Status.OK,list); 
     }catch(Exception e){ 
         log.error("查询商户的监控信息出错,请重试",e);
         if(e instanceof BusinessException){ 
             return new Result(Result.Status.ERROR,e.getMessage());
         }
         return new Result(Result.Status.ERROR,"查询商户的监控信息,请重试");
     }
    }
    
    

}
